package com.doubleview.hutool;

import cn.hutool.json.JSON;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import lombok.Data;

/**
 * @author huchengchao <huchengchao@kuaishou.com>
 * Created on 2022-05-07
 */
public class JsonUtilTest {

    public static void main(String[] args) {
        System.out.println(JSONUtil.parse("abc"));
        System.out.println(JSONUtil.toJsonStr("abc"));
        Hello hello = new Hello();
        hello.setName("aaa");
        String str = "{\"a\":\"b\"}";
        JSON json = JSONUtil.parse(str);
        hello.setData(json);

        System.out.println(JSONUtil.parseObj(hello).toString());

        JSONObject jsonObject = new JSONObject();
        jsonObject.putOnce("hello", json);
        System.out.println(jsonObject.toStringPretty());
    }

    @Data
    private static class Hello {
        private String name;
        private Object data;
    }
}
